﻿using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Pc_Vision.View_Datalayer
{
    public partial class viewProduct : System.Web.UI.Page
    {

        public void fn_Cancel(object sender, EventArgs e)
        {
            //moggele
            Response.Redirect("Index.aspx");
        }

        public void fn_SaveProduct(object sender, EventArgs e)
        {
            String check = "";

            Model.Product product = new Model.Product();
            product.name = tbName.Text;
            product.articleNumber = tbArticleNumber.Text;
            product.productDescription = tbProductDescription.Text;
            product.systemType = tbSystemType.Text;
            product.processor = tbProcessor.Text;
            product.memory = tbMemory.Text;
            product.storage = tbStorage.Text;
            product.opticalDisk = tbOpticalDisk.Text;
            product.display = tbDisplay.Text;
            product.videoCard = tbVideoCard.Text;
            product.networkCard = tbNetworkCard.Text;
            product.battery = tbBattery.Text;
            product.dimension = tbDimension.Text;
            product.warranty = tbWarranty.Text;
            if (cbInStock.Checked == false) { check = "1"; }
            else { check = "0"; }
            product.inStock = check;
            product.buyIn = tbBuyIn.Text;
            product.sellPrice = tbSellPrice.Text;
            product.actionPrice = tbActionPrice.Text;
            product.weight = tbWeight.Text;
            product.categorieID = ddlCategorie.SelectedIndex.ToString();
            product.rating = ddlRating.SelectedIndex.ToString();


            DAOFactorys.DAOproduct daoProduct = new DAOFactorys.DAOproduct();
            daoProduct.InsertProduct(product);

           // product.fn_ReturnProduct();
        }



        protected void Page_Load(object sender, EventArgs e)
        {

        }

        
        protected void UploadButton_Click(object sender, EventArgs e)
{
    
            string filename = Path.GetFileName(FileUploadControl.FileName);
            FileUploadControl.SaveAs(Server.MapPath("~/") + filename);
            StatusLabel.Text = "Upload status: File uploaded!";
        
    
}
       
        
        
    }
}